<?php

if ($VIEW[passremembering]) {

	if ($_POST[doauth]) {

        	$email = Normalize($_POST[email]);
			$callsign = Normalize($_POST[callsign]);

			$r = mysql_query("select * from pilots where callsign='$callsign'");
            $pilot = mysql_fetch_assoc($r);

            $army_r = mysql_query("select * from armies where id='".$pilot[ArmyID]."'");
            $army = mysql_fetch_assoc($army_r);
            $army = $army[name];

            if ($email and $callsign and ($email == $pilot[email])) {


	            // To send HTML mail, the Content-type header must be set
	            $headers  = 'MIME-Version: 1.0' . "\r\n";
	            $headers .= 'Content-type: text/plain; charset=win-1251' . "\r\n";
	            $headers .= "From: <".smtpfrom.">" . "\r\n";

	            $message = "Side: ".$army."\r\nPilot callsign: ".$pilot[callsign]."\r\nPilot password: ".$pilot[password]."\r\n";

	            $a = smtpmail($pilot[email],"Password recovery (".$G["description"].")",$message,$headers);

                if (!$a) {
		            $TPmain = new TemplateHandler(PasswordRememberingRes);
		            $TPmain->AssignTag("<!--Res-->",$SLANG[$lang][reg][mailsended]);
                }
                else {
	                $TPmain = new TemplateHandler(PasswordRememberingRes);
	                $TPmain->AssignTag("<!--Res-->",$a);
                }
            }
	        else {
    	        $TPmain = new TemplateHandler(PasswordRememberingRes);
	            $TPmain->AssignTag("<!--Res-->",$SLANG[$lang][reg][mailnotsended]);
	        }
    }
    else {

		$TPmain = new TemplateHandler(PasswordRemembering);

    }
}
else {

     	header("Location: $SiteURL");
		exit;

}

?>